<template>
	<ComIndex ref="commonIndexRef" :toggleView="false" :showFilter="false" :params="{ dataType: tabValue, keywords, menuType }" :isInitList="false" :initApi="false" :getListFun="ApiFieldsList">
		<template #search>
			<Search :showSearch="false" :isBtn="false">
				<!-- <template #right>&nbsp;</template> -->
			</Search>
		</template>
		<template #content>
			<Form></Form>
		</template>
	</ComIndex>
</template>
<script lang="ts" setup>
import ComIndex from "@/components/ComIndex/Index.vue";
import Form from "./components/Form.vue";
import { Message } from '@arco-design/web-vue';
const props = defineProps({
    userType:{type:String,default:()=>'info'},//info:个人信息,password:密码
})

const formRef=ref(null);
const userInfo=ref({
    email:'',
    phone:'18523654789',
    name:'张三',
    oldPassword:'',
    password:'',
    password2:''
});
const rules=reactive({
    name:{required:true,message:'请输入名字'},
    phone:{required:true,message:'请输入手机号'},
    oldPassword:{required:true,message:'请输入旧密码'},
    password:{required:true,message:'请输入新密码'},
    password2:{required:true,message:'请再次输入新密码'},
})
// 获取个人信息
const getInfo=()=>{

};
// 提交
const handleSubmit=async ()=>{
    const valid=await formRef.value.validate();
    if(valid) return
    if(props.userType=='password'){
        if(userInfo.value.password!=userInfo.value.password2){
            Message.error('两次新密码输入不一致')
        }
    }

};
// 重置
const handleReset=()=>{
    formRef.value.resetFields();
};
watch(()=>props.userType,(e)=>{
    if(e=='info'){
        getInfo()
    }
    if(formRef.value){
        formRef.value.resetFields();
    }
})
</script>
<style lang="scss" scoped>
.info {
    height: 100% ;
    width: 100%;
    position: relative;
    &-btn {
        position: absolute;
        bottom: 0;
        height: 50px;
        width: 100%;
        border-top: 1px solid #f1f1f1;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
</style>
